from appium.webdriver.common.appiumby import AppiumBy
from base.authorize_base import AuthorizeBase
from appium.webdriver import Remote


class AuthorizePage(AuthorizeBase):

    # 点击温馨提示的确定按钮
    def privacy_agree_button_click(self, driver: Remote):
        privacy_agree_button_xpath = self.privacy_agree_button()
        return self.click_new(driver, AppiumBy.XPATH, privacy_agree_button_xpath)

    # 点击授权页的确定按钮
    def authorize_agree_button_click(self, driver: Remote):
        authorize_agree_button_xpath = self.authorize_agree_button()
        return self.click_new(driver, AppiumBy.XPATH, authorize_agree_button_xpath)

    # 点击新人广告页的关闭按钮
    def ad_close_button_click(self, driver: Remote):
        ad_close_button_xpath = self.ad_close_button()
        return self.click_new(driver, AppiumBy.XPATH, ad_close_button_xpath)

    def authorize_setup(self, driver):
        self.privacy_agree_button_click(driver)
        self.authorize_agree_button_click(driver)
        self.ad_close_button_click(driver)

    def authorize_assert(self, driver, img_name):
        """
            访问首页后判断图书标签
            :param driver:
            :param img_name:
            :return:
            """
        return self.find_img_in_source(driver, img_name)
